package com.xp.flower.qsd.utils.weixin;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class WeiXinGlobalConstants {

    private static Properties interfaceUrl = new Properties();
    
    public static Properties getProperties(){
        return interfaceUrl;
    }
    
    private WeiXinGlobalConstants(){}
    
    public static String getProperties(String key){
        return interfaceUrl.getProperty(key);
    }
    
    static{
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        InputStream in = null;
        Properties props = new Properties();
        try {
            in = cl.getResourceAsStream("interface_url.properties");
            props.load(in);
            for(Object key : props.keySet()){
                WeiXinGlobalConstants.getProperties().put(key, props.get(key));
            }
            
            props = new Properties();
            in = cl.getResourceAsStream("wechat.properties");
            props.load(in);
            for(Object key : props.keySet()){
                WeiXinGlobalConstants.getProperties().put(key, props.get(key));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(in!=null){
                try {
                   in.close();
                } catch (IOException e) {
                   e.printStackTrace();
                }
            }
        }
    }
    
}
